package a3;

import java.util.HashMap;
import java.util.AbstractMap.SimpleEntry;

public class MiniMax{
	HashMap<String, Float> Q = new HashMap<String, Float>();
	HashMap<String, Float> V = new HashMap<String, Float>();
	HashMap<String, Float> pi = new HashMap<String, Float>();
	float initQ = 1f;
	float initV = 1f;
	float initPi = 1f/5f;
	float alpha = 0.5f;
	float decay = 0.999f;
	public MiniMax(){}
	
	public Float getQ(Sao sao)
	{
		if( Q.containsKey(sao.toString()))
		{
			return Q.get(sao.toString());
		}
		else
		{
			return initQ;
		}
	}
	
	public Float getV(State s)
	{
		if( V.containsKey(s.toString()))
		{
			return V.get(s.toString());
		}
		else
		{
			return initV;
		}
	}
	
	public Float getPi(SimpleEntry<State, Action> saPair)
	{
		if( pi.containsKey(saPair.toString()))
		{
			return pi.get(saPair.toString());
		}
		else
		{
			return initPi;
		}
	}
	
	public void setQ(Sao sao, Float value)
	{
		Q.put(sao.toString(), value);
	}
	public void setV(State s, Float value)
	{
		V.put(s.toString(), value);
	}
	public void setPi(SimpleEntry<State, Action> saPair, Float value)
	{
		pi.put(saPair.toString(), value);
	}
	
		
	public void decay(){
		alpha *= decay;
	}
	public void clear()
	{
		Q = new HashMap<String, Float>();
		V = new HashMap<String, Float>();
		pi = new HashMap<String, Float>();
	}
	
	
}
